{extend name='table'}

{block name="button"}
<a class="layui-btn layui-btn-sm layui-btn-primary" data-modal="{:url('customer')}">添加用户</a>
{/block}

{block name="content"}
<div class="think-box-shadow">
    {include file='dao/user_search'}
    <table id="OplogTable" data-url="{:request()->url()}" data-target-search="form.form-search"></table>
</div>
{/block}

{block name='script'}
<script>
    $(function () {
        $('#OplogTable').layTable({
            even: true, height: 'full',
            cols: [[
                {checkbox: true},
                {field: 'zh', title: '用户账号', minWidth: 180, align: 'center'},
                {field: 'name', title: '用户名', minWidth: 180, align: 'center'},
                {field: 'mm', title: '密码', minWidth: 180, align: 'center'},
                {field: 'a2', title: '开始时间', minWidth: 200, sort: true, align: 'center'},
                {field: 'b1', title: '结束时间', minWidth: 200, sort: true, align: 'center'},
                {
                    field: 'vip', title: '会员类型', minWidth: 200, align: 'center', templet: function (d) {
                        if (d.vip == 'vip') {
                            return '<b class="color-green">白银会员</b>'
                        } else if (d.vip == 'svip') {
                            return '<b class="color-blue">黄金会员</b>';
                        } else if (d.vip == 'mvip') {
                            return '<b class="color-red">钻石会员</b>';
                        } else {
                            return '<b class="color-grey">非会员</b>';
                        }
                    }
                },
                {
                    field: 'day_diff', title: '剩余天数', minWidth: 200, align: 'center'
                },
                {field: 'b5', title: '注册时间', minWidth: 200, align: 'center', sort: true},
                {toolbar: '#toolbar', title: '{:lang("操作")}', align: 'center', minWidth: 300, fixed: 'right'}
            ]]
        });
    });
</script>

<script type="text/html" id="toolbar">
    <a data-iframe='{:url("record")}?zh={{d.zh}}' class="layui-btn layui-btn-xs layui-bg-blue" style="border: none">档案详情</a>
    <a class="layui-btn layui-btn-xs" data-title="添加会员" data-modal='{:url("add")}?zh={{d.zh}}'>添加会员</a>
    <a class="layui-btn layui-btn-xs layui-bg-orange" style="border: none" data-confirm="确定要取消该用户的会员身份吗？" data-action='{:url("cancel")}?zh={{d.zh}}'>取消会员</a>
    <a class="layui-btn layui-btn-xs layui-bg-red" style="border: none" data-confirm="删除后无法恢复！确定要删除该用户吗？" data-action='{:url("delete")}?zh={{d.zh}}'>删除用户</a>
</script>
{/block}